<extend name="Layout:ly2"/>

<block name="head">
<script type="text/javascript">
$(function(){
    $('#mobile').keyup(function(){
        var mobile = $("input[name='mobile']").val();
        if(mobile.length == 11){
            $.get("{:U('Admin/Expert/getMemberID')}",{"mobile":mobile},function(data){
                if(data > 0){
                    $('.tips').html('会员ID：'+data);
                    $('#userid').val(data);
                }else{
                    $('.tips').html(' × 账号不存在');
                    $('#userid').val('');
                }
            }, "json");
        }else{
            $('.tips').html('必须为手机号码');
            $('#userid').val('');
        }
    });

    $("#btn-submit").click(function(){
        var userid = $("input[name='userid']").val();
        var name = $("input[name='name']").val();
        var expert_type = $("input[name='expert_type']").val();
        var good_at_crop = $("input[name='good_at_crop']").val();
        var good_at_area = $("input[name='good_at_area']").val();
        var qq = $("input[name='qq']").val();
        var postion = $("input[name='postion']").val();
        var company = $("input[name='company']").val();
        var content = $("textarea").val();
        if (userid == '') {layer.msg('会员ID不能为空');return false;}
        if (name == '') {layer.msg('专家名不能为空');return false;}

        $.get("{:U('Admin/Expert/expert_add')}",{'action':'add','userid':userid,'name':name,'expert_type':expert_type,'good_at_crop':good_at_crop,'good_at_area':good_at_area,'qq':qq,'postion':postion,'company':company,'content':content},function(msg){
            if(msg == 1){
                layer.msg("添加成功，1秒后自动关闭~~",{ico:1,time:1000},function(){
                    parent.window.location.reload();    //刷新父页面
                })
            }else{
                layer.msg("添加失败，1秒后自动关闭~~",{ico:1,time:1000},function(){
                    parent.window.location.reload();    //刷新父页面
                })
            }
        })
    })
})
</script>

</block>

<block name="body">
    <div class="container-fluid">
        <h3 id="title" align="center">添加专家</h3>
        <div class="padding20">
            <div class="form-horizontal p90">

                <div class="form-group">
                    <label class="col-sm-2 control-label">用户帐号：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control nobg" id="mobile" name="mobile" value="" />
                    </div>
                    <div class="col-sm-2">
                        <span class="tips">必须为手机号码</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">会员ID：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" id="userid" name="userid" value="" readonly />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">专家名称：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="name" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">专家类型：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="expert_type" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">擅长作物：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="good_at_crop" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">擅长地区：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="good_at_area" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">QQ：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="qq" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">职称：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="postion" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">单位：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control nobg" name="company" value="" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">个人介绍：</label>
                    <div class="col-sm-10">
                        <textarea class="form-control" class="content" name="content" rows="3"></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" id="btn-submit" class="btn btn-success">提交</button>&nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="reset" class="btn btn-default">重置</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

</block>